package pers.course.exam;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;

public class Fruits1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        sc.nextLine();
        Map<String, Integer> map = new HashMap<>();
        int temp = 0;
        for (int i = 0; i < m; i++) {
            String str = sc.nextLine();
            if (map.containsKey(str)) {
                temp = map.get(str);
                map.put(str, temp + 1);
            } else {
                map.put(str, 1);
            }
        }
        Set<Entry<String, Integer>> set = map.entrySet();
        int[] arr2 = new int[set.size()];
        int index = 0;
        for (Entry<String, Integer> ss : set) {
            arr2[index] = ss.getValue();
            index++;
        }
        Arrays.sort(arr2);//从小到大
        long min = 0;
        long max = 0;
        for (int i = 0; i < arr2.length; i++) {
            min += (long) arr2[arr2.length - 1 - i] * arr[i];
            max += (long) arr2[arr2.length - 1 - i] * arr[arr.length - i - 1];
        }
        System.out.println(min + " " + max);
        sc.close();
    }
}